﻿using System;
using System.IO;
using ProjScan.Config;
using ProjScan.ScanRule;
using ProjScan.ScanRule.Attr;
using ProjScan.Tools;

namespace ProjScan.Modules
{
	// Token: 0x0200030C RID: 780
	internal class GlobalSettingsCheckModule : BaseModules<GlobalSettingsCheckModule, GlobalSettingsConfig>
	{
		// Token: 0x06001261 RID: 4705 RVA: 0x00056184 File Offset: 0x00054384
		public override void Run(StreamWriter ruleStreamWriter)
		{
			Singleton<PerformanceMeasurer>.Instance.PushState("Global_Settings_Check");
			ScanLog.Instance.LogInfo(Module.Global_Settings_Check);
			ToolsHelper.ShowProgressBar("Global Settings Check", "Initializing...", 0.01f, false);
			this.rulesSw = ruleStreamWriter;
			this.Init();
			this.LoadRules(LoadMode.Check);
			bool flag = this.baseRules_Check == null || this.baseRules_Check.Count == 0;
			if (flag)
			{
				ScanLog.Instance.LogInfo(Module.Basic_Assets_Check, ScanLog.Stage.s2, "Rules is empty");
				ScanLog.UnityLogError("全局设置检查运行失败：相关规则全部关闭");
				this.Close();
			}
			else
			{
				this.InitRules(2000);
				foreach (GlobalRule globalRule in this.globalRules_Check)
				{
					globalRule.Run();
					globalRule.OutputData(false);
					globalRule.OutputDetailData();
					globalRule.DumpToRuleCSV(ref this.rulesSw);
				}
				ScanLog.Instance.LogInfo(Module.Global_Settings_Check, ScanLog.Stage.s4, "Done.");
				this.Close();
			}
		}

		// Token: 0x06001262 RID: 4706 RVA: 0x000562AC File Offset: 0x000544AC
		public override void Init()
		{
			this.config = (Singleton<ConfigMgr>.Instance.GetConfig<GlobalSettingsConfig>() as GlobalSettingsConfig);
			this.baseRules_Check.Clear();
			this.ruleAttr = typeof(GlobalEditorSettingRuleAttr);
			this.recordRules_Check.Clear();
			this.globalRules_Check.Clear();
		}

		// Token: 0x06001263 RID: 4707 RVA: 0x000089B8 File Offset: 0x00006BB8
		public override void Close()
		{
			Singleton<PerformanceMeasurer>.Instance.CloseAndRecordState();
			Singleton<PerformanceMeasurer>.Instance.AddExecutionCheckpoint("GlobalSettingsCheckEnd");
			ScanLog.Instance.LogInfo(Module.Global_Settings_Check, ScanLog.Stage.s6, "Done.");
		}
	}
}
